// Texas A&M University          //
// cpsc350 Computer Architecture //
// $Id: extender.v,v 1.1 2001/11/07 19:25:23 miket Exp miket $ //
// A insize->outsize sign extender //
//use in place of signextend to switch between sign/zero extender operations.


module extender(out, in, ExtOp);

   parameter INSIZE = 16, OUTSIZE = 32;
   
   input [INSIZE-1:0] in;
   input ExtOp;
   output [OUTSIZE-1:0] out;
   
   reg [OUTSIZE-1:0] out;
	
  always @ (in or ExtOp)
      begin
    if (ExtOp == 0) begin
		//zero extension
			#5 assign out = {{16'd0}, in};
		end 
		else 		
		begin
		//sign extension
	    #5 assign out = {{ OUTSIZE-INSIZE {in[INSIZE-1]}}, in};
		end
      end
endmodule
